//
//  OAAddWorkVC.m
//  OA项目
//
//  Created by innofive on 2018/4/16.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "OAAddWorklistManagerVC.h"
#import "MainTabBarViewController.h"
#import "MCSwitchTabControl.h"
#import "OAApprovelistCell.h"
#import "OAApproveDetailsVC.h"
#import "OAApproveRejectedVC.h"
#import "OAAddWorkDetailsVC.h"
@interface OAAddWorklistVC ()

@end


@implementation OAAddWorklistVC

- (void)viewDidLoad {
    [super viewDidLoad];

}

-(void)onLoadViewByWillAppear:(UITableView *)view
{
    view.backgroundColor = hexCOLOR(@"F1F1F1");
    view.separatorStyle = UITableViewCellSeparatorStyleNone;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 10;
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

-(MCCellInfo *)tableView:(UITableView *)tableView cellForIndexPath:(NSIndexPath *)indexPath IsHeight:(BOOL)isheight
{
    return [MCCellInfo configForCellId:cell Class:[OAAddWorklistCell class] Height:kFitH(85) TableView:tableView];
}

-(MCHFViewInfo *)tableView:(UITableView *)tableView FooderInSection:(NSInteger)section isBiao:(BOOL)isBiao
{
    return [MCHFViewInfo configForViewId:foodter Class:[OAAddWorklistFooder class] Height:kFitH(70) TableView:tableView];
}

#pragma mark 点击方法
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self onSelectVCForIndexPath:indexPath];
}
-(void)onSelectFooder:(UITapGestureRecognizer *)tapGestureRecognizer
{
    OAApprovelistFooder *fooderView = (OAApprovelistFooder *)[tapGestureRecognizer view];

    NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:fooderView.section];

    [self onSelectVCForIndexPath:indexPath];
}


-(void)onSelectVCForIndexPath:(NSIndexPath *)indexPath
{
    id model = [self modelForIndexPath:indexPath];
    OAAddWorkDetailsVC *vc = [[OAAddWorkDetailsVC alloc]initWithStyle:(UITableViewStylePlain)];
    vc.title = @"加班审批";
    [self pushToVC:vc model:model];
}

-(void)onClick:(UIButton *)button
{
    OAApproveRejectedVC *vc =[OAApproveRejectedVC rejectedVCForType:button.tag==10?openVCTypeOne:openVCTypeTwo];
    
    [self presentWindowToVC:vc IsNaV:NO Completion:^{
        
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end




@interface OAAddWorklist1VC ()

@end

@implementation OAAddWorklist1VC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end





@interface OAAddWorklist2VC ()

@end

@implementation OAAddWorklist2VC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end


@interface OAAddWorklistManagerVC ()<panGestureRecognizerDelegate>
@property(nonatomic,strong)MainTabBarViewController *tabBarC;
@property(nonatomic,strong)MCSwitchTabControl *tabControl;

@end

@implementation OAAddWorklistManagerVC

    - (void)viewDidLoad {
        [super viewDidLoad];
        
        
        OAAddWorklistVC  *vc  = [[OAAddWorklistVC alloc]initWithStyle:(UITableViewStyleGrouped)];
        //    vc.view.backgroundColor = [UIColor yellowColor];
        
        OAAddWorklist1VC *vc1 = [[OAAddWorklist1VC alloc]initWithStyle:(UITableViewStyleGrouped)];
        //    vc1.view.backgroundColor = [UIColor redColor];
        
        OAAddWorklist2VC *vc2 = [[OAAddWorklist2VC alloc]initWithStyle:(UITableViewStyleGrouped)];
        //    vc2.view.backgroundColor = [UIColor brownColor];
        
      
        NSArray *vcs = @[vc,vc1,vc2];
        MainTabBarViewController *tabBarC = [MainTabBarViewController new];
        tabBarC.panGestureDelegate = self;
        tabBarC.tabBar.hidden = YES;
        tabBarC.viewControllers = vcs;
        [self addChildViewController:tabBarC];
        [self.view addV:tabBarC.view];
        _tabBarC = tabBarC;
    }
    
    -(void)onLoadViewByWillAppear:(UIView *)view
    {
        MCSwitchTabControl *v = [MCSwitchTabControl new];
        [v addTarget:self action:@selector(onClickChangeBtn:) forControlEvents:UIControlEventValueChanged];
        [v insertSegmentWithTitle:@"待审核" image:nil];
        [v insertSegmentWithTitle:@"已审批" image:nil];
        [v insertSegmentWithTitle:@"全部" image:nil];
        [view addV:v];
        _tabControl = v;
        WSELF(weakSelf);
        [self onMainQueueAddSub:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
            v.frame = CGRectMake(0, 0, size.width,kFitH(45));
            weakSelf.tabBarC.view.frame = CGRectMake(0,kFitH(45),size.width,size.height-kFitH(45));
        }];
    }
    
    -(void)onClickChangeBtn:(MCSwitchTabControl *)button
    {
        self.tabBarC.selectedIndex = button.selectedSegmentIndex;
        [button segmentLineScrollToIndex:button.selectedSegmentIndex animate:YES];
    }
    
    -(void)tabBarViewController:(MainTabBarViewController *)tabBarViewController SelectedIndex:(NSInteger)selectedIndex
    {
        _tabControl.selectedSegmentIndex =selectedIndex;
        [_tabControl segmentLineScrollToIndex:selectedIndex animate:YES];
    }
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
